package net.bxx2004.cp.commands.subs;

import net.bxx2004.cp.CloudPlugin;
import net.bxx2004.pandalib.pcommands.PSubcommands;
import net.bxx2004.pandalib.planguage.PMessage;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class ListPluginCommand extends PSubcommands {
    @Override
    public String getName() {
        return "list";
    }

    @Override
    public String getDescription() {
        return "获取已载入插件列表";
    }

    @Override
    public boolean performCommand(CommandSender commandSender, String[] strings) {
        if (strings.length >= 0){
            if (strings[0].equalsIgnoreCase("list")){
                Player player = (Player) commandSender;
                if (player.hasPermission("cp.use")){
                    List<String> list = new ArrayList<>();
                    for (String s : CloudPlugin.plugins.keySet()){
                        list.add("&a- " + s);
                    }
                    PMessage.toList(player,list);
                }else {
                    PMessage.to(player, "&c你没有权限...");
                }
            }
        }
        return false;
    }
}
